﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ClienteConsulta.aspx.cs" Inherits="NewTierra.Pages.Cliente.ClienteConsulta" %>

<!DOCTYPE html>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" tagprefix="ajaxToolkit"%>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="cc1" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    
      <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
      <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
      <script type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>

      <link href="~/Styles/EstiloGeral.css" rel="stylesheet" type="text/css" />

    <style type="text/css">
        #Cliente
        {
            width: 1312px;
            height: 708px;
        }
        #ClienteForm
        {
            height: 649px;
            width: 1281px;
        }
        #ClienteForm .FiltrosCliente
        {
            border: 1px solid #999;
            margin-bottom: 5px;
            padding: 10px;
            background-color: #EEE;
            height: 65px;
            background: #FAFAFA;
	        color: #666;
        }
        #ClienteForm .CliCadastro
        {
            height: 434px;
            float: left;
            width: 594px;
        }
        #SetCliente
        {
            height: 620px;
            width: 1287px;
        }
        .CliEsq
        {
            width: 605px;
            height: 595px;
            float: left;
        }
        .CliDir
        {
            height: 594px;
            float: left;
            width: 605px;
            margin-left: 20px;
        }
        .ClienteFormularioCrud
        {
            height: 490px;
            padding: 5px;
            display:inline;
	        float: left;
	        position: relative;
            border:1px solid #E6E6E6;
	        background: #FAFAFA;
	        color: #666;
            top: 0px;
            left: 0px;
        }
        .ClienteFormularioCrud .CliCadastroEsq
        {
            width: 335px;
            float: left;
            height: 388px;
        }
        .ClienteFormularioCrud .CliCadastroDir
        {
            width: 250px;
            float: left;
            height: 389px;
        }
        .ClienteFormularioCrud .CliCadastroBotoes
        {
            width: 584px;
            height: 47px;
            float: left;
        }
        .Contatos
        {
            height: 565px;
            width: 559px;
        }
    </style>
</head>
<body>

    <script type="text/javascript">

        jQuery(function ($) {
            $.datepicker.regional['pt-BR'] = {
                closeText: 'Fechar',
                prevText: '&#x3c;Anterior',
                nextText: 'Pr&oacute;ximo&#x3e;',
                currentText: 'Hoje',
                monthNames: ['Janeiro', 'Fevereiro', 'Mar&ccedil;o', 'Abril', 'Maio', 'Junho',
             'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
                monthNamesShort: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun',
             'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
                dayNames: ['Domingo', 'Segunda-feira', 'Ter&ccedil;a-feira', 'Quarta-feira', 'Quinta-feira', 'Sexta-feira', 'Sabado'],
                dayNamesShort: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab'],
                dayNamesMin: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab'],
                weekHeader: 'Sm',
                dateFormat: 'dd/mm/yy',
                firstDay: 0,
                isRTL: false,
                showMonthAfterYear: false,
                yearSuffix: ''
            };
            $.datepicker.setDefaults($.datepicker.regional['pt-BR']);
        });

        $(function () {
            $("#txtSinceDataCliente").datepicker({
                defaultDate: "+1w",
                changeMonth: true,
                numberOfMonths: 1
                });
            });

        function CallServerCliente() {
            document.getElementById('<%= btnFiltroNomeClientes.ClientID %>').click();
        }

        function OpenInfos(siteInfos) {
            var home = siteInfos;
            javascript: window.open(home);
        }

        function AbrirPopUp(url, title, w, h) {
            var left = (screen.width / 2) - (w / 2);
            var top = (screen.height / 2) - (h / 2);
            return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left + '');
        }

        function ShowIcon() {
            var e = document.getElementById("processing");
            e.style.visibility = (e.style.visibility == 'visible') ? 'hidden' : 'visible';
        }
    </script>

    <form id="formulario" runat="server">

        <asp:ScriptManager ID="ScriptManagerCliente" runat="server">
        </asp:ScriptManager>

        <div id="Cliente">
    
             <h2 class="titulo">Clientes</h2>
            <hr />

                 <div id="ClienteForm">
                     <fieldset id="SetCliente">
                         <legend><h3 style="margin-bottom: 0px">Cliente</h3></legend>

                         <div class="CliEsq">

                             <div class="FiltrosCliente radius">

                                 <asp:TextBox ID="txtClientes" runat="server" placeholder="Informe o nome do Cliente." Width="340px" MaxLength="50"></asp:TextBox>
                                 
                                 <asp:AutoCompleteExtender 
                                 ID="AutoCompleteExtenderClientes" 
                                 runat="server" 
                                 CompletionInterval="100" 
                                 DelimiterCharacters="" 
                                 EnableCaching="False" 
                                 Enabled="True"
                                 MinimumPrefixLength="1" 
                                 OnClientItemSelected="CallServerCliente" 
                                 OnClientPopulated="ShowIcon"
                                 OnClientPopulating="ShowIcon" 
                                 ServiceMethod="SearchCliente" 
                                 TargetControlID="txtClientes" ServicePath="">
                                 </asp:AutoCompleteExtender>
                                 
                                 <img id="processing" alt="load" style="visibility:hidden" src="../../images/ajax-loader.gif" />
                                 
                                 <asp:Button ID="btnFiltroNomeClientes" style = "display:none" runat="server" OnClick="CarregarClienteNome"/>
                                 <br /><br />

                                 </div>

                                <div class="ClienteFormularioCrud radius">

                                    <h2 class="headline radius"><asp:Label ID="lblClienteNomeTituloTXT" runat="server" Text="" /></h2>

                                         <div class="CliCadastro">
                                          <div class="CliCadastroEsq">

                                              <asp:TextBox ID="txtCodCliente"  runat="server" style="display: none;"/>

                                            <p class="paragrafo">
                                                <asp:Label ID="lblNomeClienteTXT" runat="server" Text="Nome:"></asp:Label><br />
                                                <asp:TextBox ID="txtNomeCliente"  runat="server" Width="300px" MaxLength="50"/>
                                                <asp:RequiredFieldValidator 
                                                ID="RqFieldNomeCliente" 
                                                runat="server" 
                                                ControlToValidate="txtNomeCliente" 
                                                ErrorMessage="*" 
                                                ValidationGroup="Salvar" 
                                                ToolTip="Campo requerido."></asp:RequiredFieldValidator>
                                            </p>

                                            <p class="paragrafo">
                                                <asp:Label ID="lblEnderecoClienteTXT" runat="server" Text="Endereço:"></asp:Label><br />
                                                <asp:TextBox ID="txtEnderecoCliente"  runat="server" TextMode="MultiLine" Width="300px" Height="44px" MaxLength="200"/>
                                                <asp:RequiredFieldValidator 
                                                ID="RqFieldEndereco" 
                                                runat="server" 
                                                ControlToValidate="txtEnderecoCliente" 
                                                ErrorMessage="*" 
                                                ValidationGroup="Salvar" 
                                                ToolTip="Campo requerido."></asp:RequiredFieldValidator>
                                            </p>
                                            
                                            <p class="paragrafo">
                                                <asp:Label ID="lblHttpTXT" runat="server" Text="Site:"></asp:Label><br />
                                                <asp:TextBox ID="txtHttp"  runat="server" Width="300px" MaxLength="100"/>                                                
                                            </p>

                                            <p class="paragrafo">
                                                <asp:Label ID="lblCepClienteTXT" runat="server" Text="Cep:"></asp:Label><br />
                                                <asp:TextBox ID="txtCepCliente"  runat="server" Width="150px" MaxLength="12"/>
                                            </p>

                                            <p class="paragrafo">
                                                <asp:Label ID="lblTelefoneClienteTXT" runat="server" Text="Telefone:"></asp:Label><br />
                                                <asp:TextBox ID="txtTelefoneCliente"  runat="server" Width="150px" MaxLength="15"/>
                                                <asp:RequiredFieldValidator 
                                                ID="RqFieldTelefone" 
                                                runat="server" 
                                                ControlToValidate="txtTelefoneCliente" 
                                                ErrorMessage="*" 
                                                ValidationGroup="Salvar" 
                                                ToolTip="Campo requerido."></asp:RequiredFieldValidator>
                                            </p>

                                            <p class="paragrafo">
                                                <asp:Label ID="lblFaxClienteTXT" runat="server" Text="Fax:"></asp:Label><br />
                                                <asp:TextBox ID="txtFaxCliente"  runat="server" Width="150px" MaxLength="15"/>
                                            </p>

                                            <p class="paragrafo">
                                                <asp:Label ID="lblEmailClienteTXT" runat="server" Text="Email:"></asp:Label><br />
                                                <asp:TextBox ID="txtEmailCliente"  runat="server" Width="200px" MaxLength="50"/>
                                                <asp:RegularExpressionValidator ID="ValidatorEmail" runat="server" ControlToValidate="txtEmailCliente" ErrorMessage="*" ToolTip="Email inválido." ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="Salvar"></asp:RegularExpressionValidator>
                                            </p>

                                          </div>

                                          <div class="CliCadastroDir">

                                            <p class="paragrafo">
                                                <asp:Label ID="lblSinceCliente" runat="server" Text="Since:"></asp:Label><br />
                                                <asp:TextBox ID="txtSinceDataCliente"  runat="server" Width="100px" MaxLength="10"/>                                                
                                            </p>

                                            <p class="paragrafo">
                                                <asp:Label ID="lblRepresentanteXlienteTXT" runat="server" Text="Representante:"></asp:Label><br />
                                                <asp:DropDownList ID="ddlRepresentante" runat="server">
                                                </asp:DropDownList>
                                            </p>

                                            <p class="paragrafo">
                                                <asp:Label ID="lblCentroCustoClienteTXT" runat="server" Text="Centro Custo:"></asp:Label><br />
                                                <asp:DropDownList ID="ddlCentroCusto" runat="server">
                                                </asp:DropDownList>
                                            </p>

                                            <p class="paragrafo">
                                                <asp:Label ID="lblMercadoClienteTXT" runat="server" Text="Mercado:"></asp:Label><br />
                                                <asp:DropDownList ID="ddlMercado" runat="server">
                                                </asp:DropDownList>
                                            </p>

                                            <p class="paragrafo">
                                                <asp:Label ID="lblBaseTarifariaTXT" runat="server" Text="BaseTarifaria:"></asp:Label><br />
                                                <asp:DropDownList ID="ddlBaseTarifaria" runat="server">
                                                </asp:DropDownList>
                                            </p>

                                            <p class="paragrafo">
                                                <asp:Label ID="lblPaisClienteTXT" runat="server" Text="País:"></asp:Label><br />
                                                <asp:DropDownList ID="ddlPais" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlPais_SelectedIndexChanged">
                                                </asp:DropDownList>
                                            </p>

                                            <p class="paragrafo">
                                                <asp:Label ID="lblCidadeClienteTXT" runat="server" Text="Cidade:"></asp:Label><br />
                                                <asp:DropDownList ID="ddlCidade" runat="server">
                                                </asp:DropDownList>
                                            </p>

                                          </div>

                                          <div class="CliCadastroBotoes">
                                                <asp:Button ID="btnNovoCliente" runat="server" Text="Salvar" CssClass="btnsGeral" OnClick="CadastrarCliente"  ValidationGroup="Salvar"  />
                                                <asp:Button ID="btnAtualizarCliente" runat="server" CssClass="btnsGeral" OnClick="AtualizarCliente" Text="Atualizar" ValidationGroup="Salvar"  />
                                                <asp:Button ID="btnExcluirCliente" runat="server" CssClass="btnsGeral" OnClick="ExcluirCliente" Text="Excluir" OnClientClick="return confirm('Excluindo esse cliente, todos os contatos do mesmo também serão excluídos. Confirma?');" />
                                                <asp:Button ID="btnLimparCliente" runat="server" CssClass="btnsGeral" OnClick="LimparCliente" Text="Limpar" /> <br />
                                                <asp:Label ID="lblMsgCadCliente" runat="server" Font-Bold="True"></asp:Label>
                                          </div>

                                         </div>

                                    </div>
                             </div>

                         <div class="CliDir">

                             <fieldset style="height: auto">
                                 <legend>Contatos</legend>

                                 <div class="Contatos">

                                     <asp:Panel ID="PanelContatos" runat="server" Visible="false">
                                         
                                         <input id="btnShowContatos" class="btnsGeral" value="Contato" onclick="AbrirPopUp('AddContato_Cliente.aspx?Tipo=novo', 'Contatos', '940', '430')" type="button" />
                                         <br /><br /><br />
                                         <asp:ImageButton ID="btnAtualizarGridContatos" ToolTip="Atualizar Contatos" runat="server" ImageUrl="~/images/Icones/icone_atualizar.gif" OnClick="AtualizaGridsContatos" />

                                      <div class="GridContatos">
    

        <asp:GridView ID="GridContatosCliente" runat="server" AllowPaging="True"
         AutoGenerateColumns="False" GridLines="None" CssClass="mGrid" PagerStyle-CssClass="pgr"
           AlternatingRowStyle-CssClass="alt" EmptyDataText="Não existe contato para esse Cliente."
            Height="16px" PageSize="8">
           <AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>

           <Columns>
           <asp:BoundField DataField="Contato_id" HeaderText="ID" ReadOnly="True" 
                     SortExpression="Contato_id" InsertVisible="False">
                 <FooterStyle CssClass="invisible" />
               <HeaderStyle CssClass="invisible" />
               <ItemStyle CssClass="invisible" />
               </asp:BoundField>

                 <asp:BoundField DataField="Contato_nome" HeaderText="Nome" 
                     SortExpression="Contato_nome"/>

                      <asp:BoundField DataField="Contato_position" HeaderText="Cargo" 
                     SortExpression="Contato_position"/>

                      <asp:BoundField DataField="Contato_telefone" HeaderText="Telefone" 
                     SortExpression="Contato_telefone"/>

                     <asp:BoundField DataField="Contato_fax" HeaderText="Fax" 
                     SortExpression="Contato_fax"/>

                     <asp:BoundField DataField="Contato_email" HeaderText="Email" 
                     SortExpression="Contato_email"/>
                     
                <asp:TemplateField HeaderText="">
                    <ItemTemplate>
                     <asp:ImageButton ID="imgBtnEditarContato" 
                        runat="server"  ToolTip="Editar Contato"
                        CommandArgument='<%# Eval("Contato_id") %>'
                        oncommand="EditarContato" ImageUrl="~/images/Icones/edit.png" />
                    </ItemTemplate>
                     <HeaderStyle Wrap="False" />
                     <ItemStyle Wrap="False" />
                </asp:TemplateField>

               <asp:TemplateField HeaderText="">
                    <ItemTemplate>
                     <asp:ImageButton ID="imgBtnExcluirContato" 
                        runat="server"  ToolTip="Editar Contato"
                        CommandArgument='<%# Eval("Contato_id") %>'
                        oncommand="ExcluirContato" ImageUrl="~/images/Icones/delete.png" />
                    </ItemTemplate>
                     <HeaderStyle Wrap="False" />
                     <ItemStyle Wrap="False" />
                </asp:TemplateField>

        </Columns>

        <PagerStyle CssClass="pgr"></PagerStyle>

        </asp:GridView>
    
    </div>                 
            </asp:Panel>                    
                                 </div>

                             </fieldset>
                         </div>



                    </fieldset>
                 </div>


        </div>

    </form>
</body>
</html>
